package leetcode.weekly.week306;

//Solution2Test
public class Solution2 {

	public int edgeScore(int[] edges) {
		int n = edges.length;
		long[] ans = new long[n];

		for (int i = 0; i < edges.length; i++) {
			ans[edges[i]] += i;
		}
		long rt = 0;
		int ansi = 0;
		for (int i = 0; i < ans.length; i++) {
			if (ans[i] > rt) {
				rt = ans[i];
				ansi = i;
			}
		}
		return ansi;
	}

}
